﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace SumOfSequenceOfFactorials
{
    class Program
    {
        static public BigInteger factorial(int number)
        {
            BigInteger sum = 1;
            for (int i = 2; i <= number; i++)
            {
                sum *= i;
            }
            return sum;
        }

        static public BigInteger pow(int number, int stepen)
        {
            BigInteger currentPow = 1;
            for (int index = 0; index < stepen; index++)
            {
                currentPow *= number;
            }
            return currentPow;
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            BigInteger sum = 1;
            for (int index = 1; index < N; index++)
            {
                sum += (factorial(index) / (pow (X, index)));
            }

            Console.WriteLine(sum);

        }
    }
}
